package com.soecode.lyf.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import com.soecode.lyf.dao.AdminDao;
import com.soecode.lyf.entity.AdminInfo;
import com.soecode.lyf.entity.Comment;
import com.soecode.lyf.entity.Sign;
import com.soecode.lyf.entity.UserInfo;
import com.soecode.lyf.service.AdminService;

@Service
public class AdminServiceimpl implements AdminService {
	@Autowired
	private AdminDao adminDao;
	
	// 删除用户
	public int deleteUser(String userid) {
		return adminDao.deleteUser(userid);
	}
	// 删除签到信息
	public int deleteSign(String userid) {
			return adminDao.deleteSign(userid);
		}
	// 删除问题信息
	public int deleteQuestion(String deleteid) {
			return adminDao.deleteQuestion(deleteid);
		}
	// 删除评论信息
	public int deleteComment(String deleteid) {
			return adminDao.deleteComment(deleteid);
		}
	//编辑用户
	public int updateUserInfo(UserInfo userinfo) {
		return adminDao.updateUserInfo(userinfo);
	}
	//获取用户表
	public List<UserInfo> getUserList(){
		return adminDao.getUserList();
	}
	// 获取签到表
	public List<Sign> getSignList(){
		return adminDao.getSignList();
	}
	// 获取签到表
	public List<Comment> getQuestionList(){
			return adminDao.getQuestionList();
	}
		// 获取签到表
	public List<Comment> getCommentList(){
			return adminDao.getCommentList();
	}
	public AdminInfo login(AdminInfo admin) {
		return adminDao.login(admin);
	}
	public int updateAdminToken(String userid, String token, String exp,String username, String password) {
		if(StringUtils.isEmpty(userid)) {
			return adminDao.UpdateToken(token,exp,username,password);
		}else {
			return adminDao.RegisterAdmin(userid,token,exp,username,password);
		}
	}
}
